<template>
  <div>
    <div v-show="isShow" class="mask">
      <div class="container" :style="{width: `${width}${width.indexOf('%') > -1 ? '' : 'px'}`}">
        <div class="close" @click="handleClose">×</div>
        <div class="header" v-if="!!title">
          {{title}}
        </div>
        <div class="content">
          <slot></slot>
        </div>
        <div class="footer"></div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    width: {
      default: `50%`
    },
    title: {
      default: ""
    },
    show: {
      default: false
    }
  },
  watch: {
    show(nv) {
      this.isShow = nv;
      console.log('show: ', nv)
    }
  },
  data() {
    return {
      isShow: false,
    };
  },
  methods: {
    handleClose() {
      this.isShow = false;
      this.$emit('update:show', false);
    }
  }
};
</script>
<style scoped>
.header { 
  padding-bottom: 10px;
  border-bottom: 1px solid #E7E7E7;
  margin-bottom: 10px;
}
.container {
  position: relative;
  background: #fff;
  border-radius: 4px;
  padding: 10px;
  width: 50%;
}
.close {
  position: absolute;
  top: 5px; 
  right: 10px;
  font-size: 20px;
  color: #ccc;
}
.mask {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 996;
}
</style>








